Hi,
bool openWorkBook(string filename) {
if(!null(objWorkbooks)) {
clear(args);
put(args, cParamFileName, filename);
if(!checkResult(oleMethod(objWorkbooks, cExcelMethodOpen, args))) { // opens the file
errorBox("Failed to open file");
return(false);
}
fileOpen = true;
return true;
}
errorBox("Workbooks collection not initialized. Check to make sure your code gets it.");
return(false);
}
Private objExcel As Excel.Application
Set objExcel = CreateObject("Excel.Application")
objExcel.Workbooks.Add (filename)
bool addWorkBookTemplate(string filename) {
if(!null(objWorkbooks)) {
clear(args);
put(args, cParamFileName, filename);
if(!checkResult(oleMethod(objWorkbooks, cMethodAdd, args))) {
errorBox("Add workbook template failed.");
return(false);
}
fileOpen = true;
return(true);
}
errorBox("Workbooks collection not initialized. Check to make sure your code gets it.");
return(false);
}
SystemAdmin - Thu Nov 22 15:36:12 EST 2012 |
Re: Open Excel template as a copy Just replace cParamFileName by the string "Template" in your arguments. Regards, Alain |
Re: Open Excel template as a copy adevicq - Fri Nov 23 04:17:43 EST 2012
Ahh.. so simple, thank you so much!
bool addWorkBookTemplate(string filename) {
if(!null(objWorkbooks)) {
clear(args);
put(args, "Template", filename);
if(!checkResult(oleMethod(objWorkbooks, cMethodAdd, args))) {
errorBox("Add workbook template failed.");
return(false);
}
fileOpen = true;
return(true);
}
errorBox("Workbooks collection not initialized. Check to make sure your code gets it.");
return(false);
}
|